home *** CD-ROM | disk | FTP | other *** search
/ Baen Library 16: The Claws That Catch Disk / Claws That Catch.iso / pc / We Few / bncontrol.htm < prev    next >
Encoding:
Extensible Markup Language  |  2008-05-01  |  12.5 KB  |  513 lines

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE html PUBLIC "+//ISBN 0-9673008-1-9//DTD OEB 1.2 Document//EN" "http://openebook.org/dtds/oeb-1.2/oebdoc12.dtd">
  3. <html xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  4.   <head>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  6.     <meta http-equiv="pragma" content="no-cache" />
  7.     <title>WebWrights Contents Manager</title>
  8.     <base target="main" />
  9. <script type="text/javascript" language="javascript"><!--
  10.  
  11. var ControlVersion = '2.0.1.6';
  12. var fonts = new Array( 'Lucida Bright,Bookman Old Style,Georgia,Times New Roman,serif', //SerifFonts
  13.                        'Lucida Sans,Verdana,Arial,Helvetica,sans-serif',                //Sans Serif Fonts
  14.                        'Lucida Console,Courier New,Courier,monospace');                 // Monospace Fonts
  15. var fnt = '';
  16. var fntIndex = 0;
  17.  
  18. var fntSize = 'medium';
  19. var fntSizeIndex = 3;
  20.  
  21. var mainBgColor = '#fffcf8';
  22.  
  23. var FirstChap = '';
  24. var BlurbPage = '';
  25.  
  26.   if (parent.innerWidth)
  27.   {
  28.     var origWidth = window.innerWidth;
  29.     var origHeight = window.innerHeight;
  30.   }
  31.  
  32. function getCookieVal (offset) {
  33.   var endstr = document.cookie.indexOf (";", offset);
  34.   if (endstr == -1)
  35.     endstr = document.cookie.length;
  36.   return unescape(document.cookie.substring(offset, endstr));
  37. }
  38.  
  39. function FixCookieDate (date) {
  40.   var base = new Date(0);
  41.   var skew = base.getTime(); // dawn of (Unix) time - should be 0
  42.   if (skew > 0)  // Except on the Mac - ahead of its time
  43.     date.setTime (date.getTime() - skew);
  44. }
  45.  
  46. function GetCookie (name) {
  47.   var arg = name + "=";
  48.   var alen = arg.length;
  49.   var clen = document.cookie.length;
  50.   var i = 0;
  51.   while (i < clen) {
  52.     var j = i + alen;
  53.     if (document.cookie.substring(i, j) == arg)
  54.       return getCookieVal (j);
  55.     i = document.cookie.indexOf(" ", i) + 1;
  56.     if (i == 0) break; 
  57.   }
  58.   return null;
  59. }
  60.  
  61. function SetCookie (name,value,expires,path,domain,secure) {
  62.   document.cookie = name + "=" + escape (value) +
  63.     ((expires) ? "; expires=" + expires.toGMTString() : "") +
  64.     ((path) ? "; path=" + path : "") +
  65.     ((domain) ? "; domain=" + domain : "") +
  66.     ((secure) ? "; secure" : "");
  67. }
  68.  
  69. function DeleteCookie (name,path,domain) {
  70.   if (GetCookie(name)) {
  71.     document.cookie = name + "=" +
  72.       ((path) ? "; path=" + path : "") +
  73.       ((domain) ? "; domain=" + domain : "") +
  74.       "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  75.   }
  76. }
  77.  
  78. function expdate()
  79. {
  80.   var edate = new Date ();
  81.   FixCookieDate (edate); // Correct for Mac date bug - call only once for given Date object!
  82.   edate.setTime (edate.getTime() + (240 * 60 * 60 * 1000)); // 240 hrs from now 
  83.   return edate;
  84. }
  85.  
  86. function isData()
  87. {
  88.   return(parent != null); // Is the data module loaded
  89. }
  90.  
  91. function isbn()
  92. {
  93.   if (isData()) return(parent.isbn);
  94. }
  95.  
  96. function lastPg()
  97. {
  98.   if (isData()) return(parent.lastPg)
  99.   else return("");
  100. }
  101.   
  102. function TheBookTitle()
  103. {
  104.   if (isData()) return(parent.TheBookTitle);    
  105. }
  106.  
  107. function GetFonts(aIndex)
  108. {
  109.   fntIndex = aIndex;  
  110.   return(fonts[aIndex]);
  111. }
  112.  
  113. function font()    
  114. {
  115.   return(fnt);
  116. }
  117.  
  118. function SetFont( aIndex)
  119. {
  120.   if (aIndex == null) aIndex=0;
  121.  
  122.   fnt = GetFonts(aIndex);
  123.   SetCookie('eWSFontIndex', aIndex, expdate());
  124.  
  125.   if (document.PageSelect.FontList != null)
  126.     document.PageSelect.FontList.selectedIndex = fntIndex;
  127.  
  128.   if (parent.main)
  129.   {
  130.     if (parent.document.tags)
  131.     {
  132.       parent.main.document.location.reload(false);
  133.     }
  134.     else
  135.     {
  136.       mainLoad(parent.main.document);
  137.     }
  138.   }
  139. }
  140.  
  141. function fontSize()
  142. {
  143.   return(fntSize);
  144. }
  145.  
  146. function SetFontSize( aIndex)
  147. {
  148.   if (aIndex == null) aIndex=3;
  149.  
  150.   fntSizeIndex = aIndex;
  151.   if (document.PageSelect.fSize != null)
  152.   {
  153.     fntSize = document.PageSelect.fSize.options[aIndex].text;
  154.  
  155.     SetCookie('eWSFontSizeIndex', aIndex, expdate());
  156.  
  157.     document.PageSelect.fSize.selectedIndex = fntSizeIndex;
  158.   } 
  159.   if (parent.main)
  160.   {
  161.     if (parent.document.tags)
  162.     {
  163.       parent.main.document.location.reload(false);
  164.     }
  165.     else
  166.     {
  167.       mainLoad(parent.main.document);
  168.     }
  169.   }
  170. }
  171.  
  172. function GetBookTitle()
  173. {
  174.   return TheBookTitle();
  175. }
  176.  
  177. function SetBookTitle(aTitle)
  178. {
  179.   if (isData()) parent.TheBookTitle = aTitle;
  180. }  
  181.  
  182. function restorePage()
  183. {
  184.   if (parent.innerWidth)
  185.     if (origWidth != window.innerWidth || origHeight != window.innerHeight)
  186.     {
  187.       history.go(0);
  188.     }
  189. }
  190.   
  191. function mainLoad(aDoc)
  192. {
  193.   {
  194.     if (aDoc.body && aDoc.body.style)
  195.     {
  196.         aDoc.body.style.fontSize = fontSize();
  197.         aDoc.body.style.fontFamily = font();
  198.         if (aDoc.setStyle) aDoc.setStyle();
  199.     }
  200.     else
  201.     if (parent.document.tags)
  202.     { 
  203.       aDoc.tags.P.textIndent = "2em";
  204.       aDoc.tags.P.marginTop = "0";
  205.       aDoc.tags.P.marginBottom = "2px";
  206.       aDoc.tags.BODY.fontSize = fontSize();
  207.       aDoc.tags.BODY.fontFamily = font();
  208.       aDoc.tags.TD.fontSize = fontSize();
  209.       aDoc.tags.TD.fontFamily = font();
  210.     }
  211.   }
  212.   aDoc.bgColor=mainBgColor;
  213.  
  214.   var aStr = '<html><head><title></title></head>';
  215.   aStr += '<body bgcolor="#000080" text="#FFFF00" style="font-family:Arial">';
  216.   aStr += '<h5>  ' + GetBookTitle() + ' ' + aDoc.title + '</h5>';
  217.   aStr += '</body></html>';
  218.  
  219.   B = parent.banner.document;
  220.   B.close();
  221.   B.open('text/html','replace');
  222.   B.write(aStr);
  223.   B.close();
  224. }
  225.  
  226. function SetPage(PgNo)
  227. {
  228.     if (parent.document.tags) return;
  229.   if (PgNo == null)
  230.   { 
  231.       if (parent.main) parent.main.location.replace(FirstChap);
  232.   }
  233.   else  
  234.   {
  235.       PgNo = parseInt(PgNo);
  236.       if (PgNo != PgNo) return;
  237.  
  238.       document.PageSelect.PageNo.value = PgNo;
  239.       var ChapNo = '';
  240.       if ((PgNo < 0) || (PgNo > lastPg()[lastPg().length - 1]))
  241.       {
  242.         document.PageSelect.PageNo.value = lastPg()[lastPg().length - 1];      
  243.         alert('Page Number is out of range for this book.' 
  244.              +' Please Enter a Page number between 0 and ' + document.PageSelect.PageNo.value);
  245.         return(false);     
  246.       }
  247.       for (i=0; i < lastPg().length; i++)
  248.       {
  249.         if (!(i==0 && lastPg()[0]==0))
  250.         {
  251.           if ((PgNo > lastPg()[i-1]) && (PgNo <= lastPg()[i]) || ((PgNo >=0) && (PgNo <= lastPg()[0])))
  252.           {
  253.             if (parent.main != null)
  254.             {
  255.               var str = ChapterFileName(i) + '#p' + PgNo;
  256.               parent.main.location.replace(str);
  257.               break;
  258.             }  
  259.           }
  260.         }
  261.       }
  262.   }
  263.   return(false);
  264. }
  265.  
  266. function PageSelect_onsubmit() 
  267. {
  268.     SetPageCookie();
  269.   return SetPage(document.PageSelect.PageNo.value);
  270. }
  271.  
  272. function FontList_onchange() 
  273. {
  274.   var nItem = document.PageSelect.FontList.selectedIndex;
  275.   SetFont(nItem);
  276. }
  277.  
  278. function fSize_onchange() 
  279. {
  280.   var CookieFntSize = null;
  281.  
  282.   nItem = document.PageSelect.fSize.selectedIndex;
  283.  
  284.   SetFontSize(nItem);
  285. }
  286.  
  287. function SetPageCookie() 
  288. {
  289.   if (document.PageSelect.PageNo == null) return;
  290.   var aIndex = parseInt(document.PageSelect.PageNo.value);
  291.   if (isNaN(aIndex)) return;
  292.   SetCookie('eWS' + isbn() + 'PageNo', aIndex, expdate());
  293. }
  294.  
  295. function ChapterFileName( nChapter )
  296. {
  297.   ChapNo = '_' + nChapter;
  298.   while (ChapNo.length < 4)
  299.   {
  300.     ChapNo = '_' + ChapNo;
  301.   }
  302.   return isbn() + ChapNo + '.htm';
  303. }
  304.  
  305. function MakeIndex()
  306. {
  307.   if (!parent.document.tags)
  308.   {
  309.   var s = '<tr><th colspan="5">';
  310.       s +='<a href="" onclick="return PageSelect_onsubmit()">Bookmark</a><br>';
  311.       s +='<input type="text" name="PageNo" size="4" value="1" ';
  312.       s +='onblur="PageSelect_onsubmit();"'; 
  313.       s +='></th></tr>\n';
  314.       document.write(s);
  315.   }
  316. }
  317.  
  318. function MakeChapTable()
  319. {
  320.       var tbl = '';
  321.       var sOut = '<tr><th colspan="5" align="center">Chapters</th></tr><tr>\n';
  322.       var prologue = 1;
  323.       
  324.       if (! isData()) return("");
  325.       
  326.       if (lastPg()[0] == 0)
  327.       {
  328.         prologue = 1;
  329.       }
  330.       else
  331.       {
  332.         prologue = 0;
  333.       }
  334.            
  335.       for (i=prologue; i < lastPg().length; i++)
  336.       {
  337.         tbl = '';
  338.  
  339.         if (FirstChap=='')
  340.           FirstChap = ChapterFileName(i);
  341.           
  342.         tbl += '<td valign="top" align="center"><b>';
  343.         tbl += '<a href="';
  344.         tbl += ChapterFileName(i);
  345.         tbl += '" target="main">';
  346.         if (i == 0)
  347.         {
  348.           tbl += 'P';
  349.         }
  350.         else  
  351.         {
  352.           tbl += i;
  353.         }
  354.           
  355.         tbl += '</a></b></td>';
  356.         
  357.         if (  ( (i-(prologue-1)) % 5) == 0 )
  358.         {
  359.           tbl +='</tr><tr>';
  360.         }      
  361.         sOut += tbl;
  362.       } 
  363.       while (((i-(1*prologue)) % 5) != 0)
  364.       {
  365.         sOut += '<td> </td>';
  366.         i++;
  367.       }
  368.       sOut += '</tr>';
  369.  
  370.       window.document.writeln(sOut);    
  371. }
  372.  
  373. function MakeCopyright()
  374. {
  375.       if (lastPg()[0] == 0)
  376.         prologue = 1;
  377.       else
  378.         prologue = 0;
  379.         
  380.       BlurbPage = isbn() + '__c_.htm';  
  381.   var s =  '<tr><th colspan="5">\n';
  382.       s += '<p>\n<a href="'+ BlurbPage + '">Cover</a></p>\n';
  383.       s += '</td></tr>\n';
  384.       s += '<tr><td colspan="5" align="center">\n';
  385.       s += '<p><a href="' + isbn() + '___'+ prologue + '.htm" target="_top"><b>Frameless</b></a></p>\n';
  386.       s += '</td></tr>\n';
  387.  
  388.   document.write(s);    
  389. }
  390.  
  391. function MakeFSize()
  392. {
  393.   if ( parent.document.tags || parent.document.body.style)
  394.   {
  395.     var i = 8;
  396.     var s = '<tr><td colspan="5" valign="top" align="center">\n';
  397.     s +='<select size="1" name="fSize" ';
  398.     s += 'width="90" ';
  399.     s +='language="javascript" onchange="return fSize_onchange()">';
  400.     s +='<option>xx-small\n';
  401.     s +='<option>x-small\n';
  402.     s +='<option>small\n';
  403.     s +='<option>medium\n';
  404.     s +='<option>large\n';
  405.     s +='<option>x-large\n';
  406.     s +='<option>xx-large\n';
  407.     while (i < 65)
  408.     {
  409.       s += '<option>'+ i + 'pt\n';
  410.  
  411.       i++;
  412.  
  413.       if (i < 12) {i++;}  
  414.  
  415.       if ((20 < i) && (i < 24)) {i++;}
  416.  
  417.       if ((24 < i) && (i < 64)) {i = i+7;}
  418.     }
  419.     
  420.     s +='</select>\n';
  421.     s +='</td></tr>\n';
  422.     document.write(s);   
  423.   }   
  424. }
  425.  
  426. function MakeFontList()
  427. {
  428.   if ( parent.document.tags || parent.document.body.style)
  429.   {
  430.     var s = '<tr><td colspan="5" valign="top" align="center">\n';
  431.       s += '<select size="1" name="FontList" ';
  432.       s += 'width="90" ';
  433.       s += 'language="javascript" onchange="return FontList_onchange()">';
  434.       s += '<option selected value="serif">serif</option>';
  435.       s += '<option value="sans-serif">sans-serif</option>';
  436.       s += '<option value="monospace">monospace</option>';
  437.       s += '</select>\n';
  438.       s += '</td></tr>';
  439.       document.write(s);
  440.    }
  441. }
  442.  
  443. function MakeRotator()
  444. {
  445.   var s = '<a href="http://www.webscription.net/ad/ebook_ad.aspx?isbn=';
  446.       s += parent.isbn;
  447.       s += '&title=';
  448.       s += TheBookTitle();
  449.       s += '"><img name="rotator" src="http://www.webscription.net/ad/ebook_banner.aspx?isbn='
  450.       s += parent.isbn;
  451.       s += '&title=';
  452.       s += escape(TheBookTitle());
  453.       s += '" border="0" vspace="5" onerror="this.style.display='
  454.       s += "'none'";
  455.       s += ';"></a>';
  456.       document.write(s);
  457. }
  458.  
  459. function Loaded()
  460. {
  461.   if (parent.main)
  462.   {
  463.     if (isData())
  464.     {
  465.       SetFont(GetCookie('eWSFontIndex'));
  466.       SetFontSize(GetCookie( 'eWSFontSizeIndex'));
  467.     }  
  468.   }
  469.  
  470.   var search = parent.document.location.search;
  471.   if (search == '?blurb')
  472.   {
  473.     parent.main.location.replace(BlurbPage);
  474.   }
  475.   else
  476.   {
  477.     SetPage(GetCookie( 'eWS' + isbn() + 'PageNo'));
  478.   }
  479. }
  480.  
  481. window.onresize=restorePage;
  482. window.onload = SetPageCookie;
  483.  
  484. //--></script>
  485.         
  486.   <style type="text/css">
  487.         body,p,td,th,input,select {font-family:Arial,Helvetica,sans-serif;}
  488.         input,select {width:75px;font-size:11px;padding:0;text-align:center}
  489.         td,input,select {font-size:11px;}
  490.         th {font-size:15px}
  491.     </style>
  492.   </head>
  493.   <body style="background-color:#000080;color:#FFFFFF;" link="#00FFFF" vlink="#FFFFFF" alink="#FF0000" onload="Loaded()" onresize="restorePage()" onunload="SetPageCookie()" >
  494.     <form method="GET" action="bncontrol.htm" name="PageSelect" id="PageSelect" onsubmit="return PageSelect_onsubmit()" target="main">
  495.       <div align="center">
  496.  
  497.         <table border="1" cellspacing="0" width="80">
  498.           <script type="text/javascript" language="JavaScript"><!--
  499.             MakeIndex();
  500.             MakeChapTable();
  501.             MakeCopyright();
  502.             MakeFSize();
  503.             MakeFontList();
  504.           //--></script>
  505.         </table>
  506.                 <script type="text/javascript" language="JavaScript"><!-- 
  507.                     MakeRotator(); 
  508.                 //--></script>
  509.       </div>
  510.     </form>
  511.   </body>
  512. </html>
  513.